package com.yc.shopping.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.yc.shopping.util.DBHelper;

public class MenberDao {
	
	/*
	 * 
	 * 添加积分
	 * 
	 */
	
	public int updateScore(String tel,int score) throws SQLException {
		String sql = "update tb_menber set score = score + ? where mid = ?";
		return DBHelper.update(sql, score,tel);
	}
	
	/*
	 * 根据会员号查看会员信息
	 */
	public Map<String,Object> findByTel(String tel) throws SQLException{
		String sql = "select tel,name,birthday,score,state from tb_menber where mid = ?";
		return DBHelper.selectOneMap(sql, tel);
	}
	
	/*
	 * 查看所有会员信息
	 */
	public List<Map<String,Object>> findAll() throws SQLException{
		String sql = "select * from tb_menber";
		return DBHelper.selectListMap(sql);
	}
	
	/*
	 * 添加会员
	 */
	public int InsertMenber(String mid,String name,String date,String state) throws SQLException {
		String sql = "insert into tb_menber values (mid,name,date)";
		return DBHelper.update(sql, mid,name,date);
	}
	
	/*
	 * 暂停会员
	 */
	public int DeleteMenber(String mid) throws SQLException {
		String sql = "update tb_menber set state = 2 where mid = ?";
		return DBHelper.update(sql, mid);
	}

}
